<?php 
	include '../init.php';
	
	$row=get_configs();

?>
<!DOCTYPE html>
<html>
<head>
	<title>基本设置</title>
	
	<link rel="stylesheet" type="text/css" href="<?php echo __PUBLIC__;?>/bootsrap/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="<?php echo __PUBLIC__;?>/webupload/webuploader.css">
	<script type="text/javascript" src="<?php echo __PUBLIC__;?>/js/jquery.js"></script>
	<script type="text/javascript" src="<?php echo __PUBLIC__;?>/bootsrap/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="<?php echo __PUBLIC__;?>/validate/jquery.validate.min.js"></script>
	<script type="text/javascript" src="<?php echo __PUBLIC__;?>/validate/localization/messages_zh.min.js"></script>
	<script type="text/javascript" src="<?php echo __PUBLIC__;?>/webupload/webuploader.js"></script>
	<script type="text/javascript" src="<?php echo __PLUGIN__;?>/ueditor/ueditor.config.js"></script>
	<script type="text/javascript" src="<?php echo __PLUGIN__;?>/ueditor/ueditor.all.js"></script>
</head>
<body background="../../public/img/bg4.jpg">
	<div>&nbsp;</div>
	<div>&nbsp;</div>
	<div class="container bg-info">
		<div class="col-md-12">&nbsp;</div>
		<div class="col-md-12">&nbsp;</div>
		<div class="row">
			<?php include '../nav.php'; ?>
		</div>
	</div>
	<div class="container text-center bg-info">
		<div class="row">
			<form action="save.php" method="post" id="articleForm" class="form-horizontal">
				<div class="col-md-12">&nbsp;</div>
				<div class="col-md-12">&nbsp;</div>
				<div class="col-md-2" style="padding-left: 20px;font-size: 18px;height: 25px;line-height: 25px;color: #000"><span class="glyphicon glyphicon-th-list"></span>  基本设置</div>
			<div class="col-md-12">&nbsp;</div>
				<div class="col-md-12 text-center">
					<input type="hidden" name="id" value="<?php if(isset($row['id'])) {
						echo $row['id'];
					} ?>">
					<div class="form-group">
						<div class="col-md-2">
							<label for="title">网站名称</label>
						</div>
						<div class="col-md-7 text-left  has-error">
							<input type="text" class="form-control" name="title" id="title" placeholder="网站名称" required="true" value="<?php if (isset($row['title'])) {
						echo $row['title'];
					} ?>" aria-describedby="inputSuccess2Status">
						<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
						<span id="inputSuccess2Status" class="sr-only">(success)</span>
						</div>
					</div>
				</div>
				<div class="col-md-12">&nbsp;</div>
				<div class="col-md-12">
					<div class="form-group">
						<div class="col-md-2">
							<label for="siteurl">网站域名</label>
						</div>
						<div class="col-md-4">
							<input type="text" class="form-control" name="siteurl" id="siteurl" placeholder="网站域名" required="true" value="<?php if (isset($row['siteurl'])) {
						echo $row['siteurl'];
					} ?>">
						<div class="col-md-6"></div>
						</div>
					</div>
				</div>
				<div class="col-md-12">&nbsp;</div>
				<div class="col-md-12">
					<div class="form-group">
						<div class="col-md-2">
							<label for="sitelogo">网站LOGO</label>
						</div>
						<div class="col-md-10"></div>
					</div>
					
				</div>
				<div class="col-md-12 ">
					<div class="form-group">
						<div class="col-md-2"></div>
						<div id="picbox" class="col-md-2">
							<?php if (isset($row['sitelogo'])&&!empty($row['sitelogo'])) { ?>
								<div class="file-item thumbnail">
									<img class="img-responsive" id="sitelogo" src="<?php echo __PUBLIC__;?>/upload/<?php echo $row['sitelogo']; ?>" width="100" height="100">
								</div>
							<?php } ?>
						</div>
						<div class="col-md-8"></div>
					</div>
					
				</div>

				<div class="col-md-12">
						<div class="form-group">
							<!-- <div class="row"> -->
								<div id="picker" class="col-md-2">上&nbsp;&nbsp;&nbsp;&nbsp;传</div>
							<!-- </div> -->
							<input type="hidden" id="sitelogo" name="sitelogo" value="<?php if (isset($row['sitelogo'])) {
						echo $row['sitelogo'];
					} ?>" placeholder="网站LOGO">
						</div>
				</div>
				<div class="col-md-12">&nbsp;</div>
				<div class="col-md-6">
					<div class="form-group">
						<div class="col-md-4">
							<label for="keyword">关&nbsp;&nbsp;键&nbsp;&nbsp;词</label>
						</div>
						<div class="col-md-4">
							<input type="text" class="form-control" name="keyword" id="keyword" placeholder="关键词" required="true" value="<?php if (isset($row['keyword'])) {
						echo $row['keyword'];
					} ?>">
						</div>
					</div>
					
				</div>
				<div class="col-md-12">&nbsp;</div>
				<div class="col-md-12">
					<div class="form-group">
						<div class="col-md-2">
							<label for="description">描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述</label>
						</div>
						<div class="col-md-8 text-left">
							<input type="text" class="form-control" name="description" id="description" placeholder="描述" required="true" value="<?php if (isset($row['description'])) {
						echo $row['description'];
					} ?>">
						</div>
					</div>
				</div>
				<div class="col-md-12">&nbsp;</div>
				<div class="col-md-12">
					<div class="form-group">
						<div class="col-md-2">
							<label for="siteqq">QQ&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号</label>
						</div>
						<div class="col-md-8 text-left">
							<input type="text" class="form-control" name="siteqq" id="siteqq" placeholder="QQ号" required="true" value="<?php if (isset($row['siteqq'])) {
						echo $row['siteqq'];
					} ?>">
						</div>
					</div>
				</div>
				<div class="col-md-12">&nbsp;</div>
				<div class="col-md-12">
					<div class="form-group">
						<div class="col-md-2">
							<label for="weichat">微&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;信</label>
						</div>
						<div class="col-md-8 text-left">
							<input type="text" class="form-control" name="weichat" id="weichat" placeholder="微信" required="true" value="<?php if (isset($row['weichat'])) {
						echo $row['weichat'];
					} ?>">
						</div>
						<div class="col-md-2"></div>
					</div>
				</div>
				<div class="col-md-12">&nbsp;</div>
				<div class="col-md-12">
					<div class="form-group">
						<div class="col-md-2">
							<label for="status">状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态</label><br>
						</div>
						<div class="col-md-2 text-left">
							<select name="status" id="status">
								<?php if (isset($row['status'])&&$row['status']==1) { ?>
									<option value="1" selected="selected">打&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;开</option>
									<option value="0">关&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;闭</option>
								<?php }else{ ?>
									<option value="1">打&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;开</option>
									<option value="0" selected="selected">关&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;闭</option>
								<?php } ?>
							</select>
						</div>
						<div class="col-md-8">&nbsp;</div>
					</div>
				</div>
				<div class="col-md-12">&nbsp;</div>
				<div class="col-md-12">
					<div class="form-group">
						<div class="col-md-2">
							<label for="address">联系地址</label>
						</div>
						<div class="col-md-8 text-left">
							<input type="text" class="form-control" name="address" id="address" placeholder="联系地址" required="true" value="<?php if (isset($row['address'])) {
						echo $row['address'];
					} ?>">
						</div>
					</div>
				</div>

				<div class="col-md-12">&nbsp;</div>
				<div class="col-md-12">
					<div class="form-group">
						<div class="col-md-4 text-right">
							<button class="btn btn-success" type="submit">保　　存</button>
						</div>
						<div class="col-md-4"></div>
						<div class="col-md-4 text-left">
							<button class="btn btn-success" type="reset">重　　置</button>
						</div>
					</div>
				</div>
			</form>
			<!-- 提示弹窗 -->
			<div class="modal fade bs-example-modal-sm" id="myModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
			    <div class="modal-dialog modal-sm" role="document">
			      <div class="modal-content">

			        <div class="modal-header">
			          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
			          <h4 class="modal-title" id="mySmallModalLabel"><span class="glyphicon glyphicon-info-sign text-warning" aria-hidden="true"></span>提示框</h4>
			        </div>
			        <div class="modal-body">
			          ...
			        </div>
			      </div>
			    </div>
			</div>
			<!-- 表单验证 -->
			<script type="text/javascript">
				$('#articleForm').validate({
				  	submitHandler: function(form) {
				    	$.ajax({
							type:'post',
							url:$('#articleForm').attr('action'),
							data:$('#articleForm').serialize(),
							dataType:'json',
							success:function(data){
								if(data.code=='000'){
									// window.location="setting.php";
									$('#myModal .modal-body').html(data.msg);
									$('#myModal').modal({'show':true});
								}else{
									$('#myModal .modal-body').html(data.msg);
									$('#myModal').modal({'show':true});
								}
							}
						});
				  	}
				});
			</script>
			<!-- AJAX表单提交 -->

			<script type="text/javascript">
				// $('#articleForm').on('submit',function(){
					
				// 	return false;
				// });
			</script>
			<!-- 文件上传 -->
			<script type="text/javascript">
				var uploader = WebUploader.create({
					// 选完文件后，是否自动上传。
		    		auto: true,
				    // swf文件路径
				    swf: '<?php echo __PUBLIC__;?>/webupload/Uploader.swf',
				    // 文件接收服务端。
				    server: '<?php echo $config['local'];?>/lib/upfile.php',
				    // 选择文件的按钮。可选。
				    // 内部根据当前运行是创建，可能是input元素，也可能是flash.
				    pick: '#picker',
				    // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
				    resize: false,

				    runtimeOrder:false,
				    // 只允许选择图片文件。
				    accept: {
				        title: 'Images',
				        extensions: 'gif,jpg,jpeg,bmp,png',
				        mimeTypes: 'image/jpg,image/jpeg,image/png',
				    }
				});
				uploader.on( 'fileQueued', function( file ) {
				    var $li = $(
		            '<div id="' + file.id + '" class="file-item thumbnail">' +
		                '<img>' +
		                '<div class="success">' + file.name + '</div>' +
		            '</div>'
		            ),
		        	$img = $li.find('img');
		        	$('#picbox').html( $li );
		        	uploader.makeThumb( file, function( error, src ) {
				        if ( error ) {
				            $img.replaceWith('<span>不能预览</span>');
				            return;
				        }

				        $img.attr( 'src', src );
				    }, 100, 100 );
				});
			    uploader.on( 'uploadSuccess', function(file,response) {
			    	if (response!='000') {
			    		$('#sitelogo').val(response._raw);
			    	}
				    
				});
				uploader.on( 'uploadError', function( file ) {
				    var $li = $( '#'+file.id ),
				        $error = $li.find('div.error');

				    // 避免重复创建
				    if ( !$error.length ) {
				        $error = $('<div class="error"></div>').appendTo( $li );
				    }

				    $error.text('上传失败');
				});
			</script>
		</div>
	</div>
	<div>&nbsp;</div>
</body>
</html>